*************************************************
*************************************************
****Replication for "Generals in the Cabinet"****
*************************************************
*************************************************

clear all

set more off

cd "C:\Users\pbw0011\Dropbox\Generals in the Cabinet v2\ISQ submission\ISQ final docs\Replication materials"
use generals_cab_data_1_3_20

*Fig1
*gen dummy for active mil officer in security role
clear all
use generals_cab_data_1_3_20

gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_democs, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title() scheme(s1mono)

*
clear all

use generals_cab_data_1_3_20

sort ccode year

**Table 1: 

logit mid_init l.cab_count_mil_act c.mid_init_pyrs##c.mid_init_pyrs##c.mid_init_pyrs, cluster(ccode)

logit mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel c.mid_init_pyrs##c.mid_init_pyrs##c.mid_init_pyrs, cluster(ccode)

logit mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.mid_init_pyrs##c.mid_init_pyrs##c.mid_init_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_mil_act c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*Table 2

logit mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act c.mid_init_pyrs##c.mid_init_pyrs##c.mid_init_pyrs, cluster(ccode)

logit mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel c.mid_init_pyrs##c.mid_init_pyrs##c.mid_init_pyrs, cluster(ccode)

logit mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.mid_init_pyrs##c.mid_init_pyrs##c.mid_init_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*Figure 2

logit fatal_mid_init l.c.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

margins, at(l.c.cab_count_mil_act=(0(1)45))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(sj) xtitle (Military officers in government) ytitle(Probability of fatal MID initiation) title(MPG and conflict initiation)

*Figure 3

logit fatal_mid_init l.c.cab_count_sec_mil_act l.c.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

margins, at(l.c.cab_count_nonsec_mil_act=(0(1)42))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(sj) xtitle (Military officers in government with non-security role) ytitle(Probability of fatal MID initiation) title(Non-security MPG and conflict initiation)


*Figures 4a-4c

*4a
logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

margins

margins l.gwf_military, at(l.c.cab_count_nonsec_mil_act=(0(1)23))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (Military officers in government with non-security role) ytitle(Probability of fatal MID initiation) title(MPG and conflict initiation) play(Figure4a)

*4b
logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

margins l.gwf_military, at(l.c.cab_count_nonsec_mil_act=(0(1)23))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (Military officers in government with non-security role) ytitle(Probability of fatal MID initiation) title(MPG and conflict initiation) play(Figure4b) 

*4c
logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

margins l.gwf_military, at(l.c.cab_count_nonsec_mil_act=(0(1)23))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (Military officers in government with non-security role) ytitle(Probability of fatal MID initiation) title(MPG and conflict initiation) play(Figure4c)


*marginal effect of miltary regime at different levels of non-security MPG

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

margins, dydx(l.gwf_military) at(l.c.cab_count_nonsec_mil_act=(0(1)23))

marginsplot

**APPENDIX**

*Descriptive statistics
sum mid_init if cab_count_mil_act!=.
sum fatal_mid_init if cab_count_mil_act!=.
sum cab_count_mil_act if cab_count_mil_act!=.
sum cab_count_sec_mil_act if cab_count_mil_act!=.
sum cab_count_nonsec_mil_act if cab_count_mil_act!=.
sum gwf_party if cab_count_mil_act!=.
sum gwf_personal if cab_count_mil_act!=.
sum gwf_mil_inst if cab_count_mil_act!=.
sum gwf_mil_pers if cab_count_mil_act!=.
sum gwf_other if cab_count_mil_act!=.
sum gwf_democracy if cab_count_mil_act!=.
sum gwf_duration if cab_count_mil_act!=. 
sum combat if cab_count_mil_act!=.
sum milnoncombat if cab_count_mil_act!=.
sum rebel if cab_count_mil_act!=.
sum maj_pow if cab_count_mil_act!=.
sum acdall if cab_count_mil_act!=.
sum totalmids if cab_count_mil_act!=.
sum cinc if cab_count_mil_act!=.

**1)Parsing non-security MPG

*separate out peripheral from central nonsec appointments
*peripheral defined as portfolios that focus solely on social, health, culture, sports, agriculture, secondary economic, housing

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act_central l.cab_count_nonsec_mil_act_periph  l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act_central##l.i.gwf_military l.c.cab_count_nonsec_mil_act_periph##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

**2)dummy var for sec/non-sec participation
ta mil_sec_d

ta mil_nonsec_d

logit fatal_mid_init l.mil_cab_d l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.mil_sec_d l.mil_nonsec_d l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.c.mil_sec_d##l.i.gwf_military l.c.mil_nonsec_d##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*dummy var w/counter

logit fatal_mid_init l.mil_cab_d l.cab_count_mil_act  l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.mil_sec_d l.mil_nonsec_d l.cab_count_sec_mil_act  l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.c.mil_sec_d##l.i.gwf_military l.c.mil_nonsec_d##l.i.gwf_military l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*3) rare events logit

*generate interaction term

gen gwf_military_secMPG=gwf_military*cab_count_sec_mil_act

gen gwf_military_nonsecMPG=gwf_military*cab_count_nonsec_mil_act

relogit lead_fatal_mid_init cab_count_mil_act gwf_party gwf_personal gwf_mil_inst gwf_mil_pers gwf_other gwf_duration  combat milnoncombat rebel maj_pow acdall totalmids cinc  lead_f_mid_pyrs lead_f_mid_pyrs2 lead_f_mid_pyrs3, cluster(ccode)

relogit lead_fatal_mid_init cab_count_sec_mil_act cab_count_nonsec_mil_act gwf_party gwf_personal gwf_mil_inst gwf_mil_pers gwf_other gwf_duration  combat milnoncombat rebel maj_pow acdall totalmids cinc  lead_f_mid_pyrs lead_f_mid_pyrs2 lead_f_mid_pyrs3, cluster(ccode)

relogit lead_fatal_mid_init cab_count_sec_mil_act gwf_military gwf_military_secMPG cab_count_nonsec_mil_act gwf_military_nonsecMPG gwf_duration combat milnoncombat rebel maj_pow acdall totalmids cinc lead_f_mid_pyrs lead_f_mid_pyrs2 lead_f_mid_pyrs3, cluster(ccode)

*4) yearly fixed effects

logit fatal_mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs i.year, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs i.year, cluster(ccode)

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs i.year, cluster(ccode)

**5) coup pyrs (Powell and Thyne)

logit fatal_mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs c.coup_a_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs c.coup_a_pyrs, cluster(ccode)

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs c.coup_a_pyrs, cluster(ccode)

*6) Including overall cabinet count

logit fatal_mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs l.cab_count, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs l.cab_count, cluster(ccode)

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs l.cab_count, cluster(ccode)

*7) Military government share

logit fatal_mid_init l.actmilcabshare l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.actmilsecshare  l.actmilnonsecshare l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.c.actmilsecshare##l.i.gwf_military l.c.actmilnonsecshare##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*8) Contiguous states and alliances as controls

logit fatal_mid_init l.cab_count_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc l.total_cont l.alliance c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.cab_count_sec_mil_act  l.cab_count_nonsec_mil_act l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc l.total_cont l.alliance c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.i.gwf_military l.c.cab_count_nonsec_mil_act##l.i.gwf_military l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc l.total_cont l.alliance c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*9) interaction w/cinc

logit fatal_mid_init l.c.cab_count_mil_act##l.c.cinc l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

logit fatal_mid_init l.c.cab_count_sec_mil_act##l.c.cinc  l.c.cab_count_nonsec_mil_act##l.c.cinc l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

*look at whether impact of non-sec MPG changes at different levels of cinc
logit fatal_mid_init l.c.cab_count_sec_mil_act##l.c.cinc  l.c.cab_count_nonsec_mil_act##l.c.cinc l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

sum l.cinc if e(sample), detail

margins, dydx(l.cab_count_nonsec_mil_act) at(l.cinc=(0(.0001).013))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (CINC score) ytitle(Effect of non-security MPG) title(Effect of non-security MPG at different CINC levels)

**look at whether impact of sec MPG changes at different levels of cinc
logit fatal_mid_init l.c.cab_count_sec_mil_act##l.c.cinc  l.c.cab_count_nonsec_mil_act##l.c.cinc l.gwf_party l.gwf_personal l.gwf_mil_inst l.gwf_mil_pers l.gwf_other l.gwf_duration  l.combat l.milnoncombat l.rebel l.maj_pow l.acdall l.totalmids l.cinc c.f_mid_pyrs##c.f_mid_pyrs##c.f_mid_pyrs, cluster(ccode)

sum l.cinc if e(sample), detail

margins, dydx(l.cab_count_sec_mil_act) at(l.cinc=(0(.0001).013))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (CINC score) ytitle(Effect on probability of fatal mid initiation) title(Effect of security MPG at different CINC levels)

*10) MID Outcomes

clear all

use outcomes_analysis

sort ccode year
*limit to fatal mids

mlogit dydoutcome l_cab_count_mil_act democa democb lgrelcapab lgally lgtrade lgigomem hostdif lgpastmids if statea<stateb & lastobs==1 &fatlev>0 & fatlev!=., base(2) 

mlogit dydoutcome c.l_cab_count_sec_mil_act c.l_cab_count_nonsec_mil_act democa democb lgrelcapab lgally lgtrade lgigomem hostdif lgpastmids if statea<stateb & lastobs==1 &fatlev>0 & fatlev!=., base(2) 
 
*substantive effects

mlogit dydoutcome c.l_cab_count_sec_mil_act c.l_cab_count_nonsec_mil_act democa democb lgrelcapab lgally lgtrade lgigomem hostdif lgpastmids if statea<stateb & lastobs==1 &fatlev>0 & fatlev!=., base(2) 

margins, at(l_cab_count_sec_mil_act=(0(1)9))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (Security MPG) ytitle(Probability of Fatal MID outcome) title(Security MPG and Fatal MID outcome)

mlogit dydoutcome c.l_cab_count_sec_mil_act c.l_cab_count_nonsec_mil_act democa democb lgrelcapab lgally lgtrade lgigomem hostdif lgpastmids if statea<stateb & lastobs==1 &fatlev>0 & fatlev!=., base(2) 
 
margins, at(l_cab_count_nonsec_mil_act=(0(1)42))

marginsplot, plotop(ms(i)) ciopts(lp(dash)) recastci(rline) scheme(s1color) xtitle (Non-security MPG) ytitle(Probability of Fatal MID outcome) title(Non-security MPG and Fatal MID outcome)

*regime-specific figures

*gen dummy for active mil officer in security role
clear all
use generals_cab_data_1_3_20

*Democracies
gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
keep if gwf_democracy==1
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_democs, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title(Democracies) scheme(s1mono)

*Party regimes
clear all
use generals_cab_data_1_3_20

gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
keep if gwf_party==1
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_party, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title(Party regimes) scheme(s1mono)

*Personalist regimes
clear all
use generals_cab_data_1_3_20

gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
keep if gwf_personal==1
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_personal, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title(Personalist regimes) scheme(s1mono)

*Military_junta
clear all
use generals_cab_data_1_3_20

gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
keep if gwf_mil_inst==1
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_junta, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title(Military regimes (juntas)) scheme(s1mono)

*Military_personalist

clear all
use generals_cab_data_1_3_20

gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
keep if gwf_mil_pers==1
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_mil_pers, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title(Military-personalist regimes) scheme(s1mono)

*Other regimes
clear all
use generals_cab_data_1_3_20

gen mil_sec_d=0 if cab_count!=.
replace mil_sec_d=1 if cab_count_sec_mil_act>=1 & cab_count_sec_mil_act!=.
gen mil_nonsec_d=0 if cab_count!=.
replace mil_nonsec_d=1 if cab_count_nonsec_mil_act>=1 & cab_count_nonsec_mil_act!=.
keep if gwf_other==1
sum year if cab_count!=.
keep if year>=1964 & year<=2008
sum year
collapse (mean) mil_sec_d mil_nonsec_d, by (year)
sort year
label var mil_sec_d "Security role"
label var mil_nonsec_d "Non-security role"
save fig1_other, replace
twoway (line mil_sec_d year) (line mil_nonsec_d year), xtitle(Year) ytitle(Proportion of states) title(Other non-democratic regimes) scheme(s1mono)

